<template>
  <!--
    作者：luoyiming
    时间：2020-06-04
    描述：插件中心-积分商城-商品设置-编辑商品-其它
  -->
  <div>
    <div class="common-form">其它</div>

    <el-form-item label="拼团类型">
      <el-radio-group v-model="form.teamwork_type">
        <el-radio :label="1">开团人数</el-radio>
        <el-radio :label="2">开团订单数</el-radio>
        <el-radio :label="3">开团商品数</el-radio>
      </el-radio-group>
    </el-form-item>
    
    <div v-if="form.teamwork_type ==1">
      <el-form-item label="限购数量" prop="limit_num" :rules="[{ required: true, message: '请填写限购数量' }]">
        <el-input type="number" v-model="form.limit_num" class="max-w460"></el-input>
      </el-form-item>
      <el-form-item label="开团人数" prop="assemble_num"
        :rules="[{ required: true, message: '开团人数最少为2',validator:assembleLimitnum }]">
        <el-input type="number" v-model="form.assemble_num" class="max-w460"></el-input>
      </el-form-item>
    </div>

    <div v-else-if="form.teamwork_type ==2">
      <el-form-item label="开团订单数" prop="order_number"
        :rules="[{ required: true, message: '开团订单数最少为2',validator:orderNumber }]">
        <el-input type="number" v-model="form.order_number" class="max-w460"></el-input>
      </el-form-item>
    </div>
    <div v-else>
      <el-form-item label="开团商品数" prop="product_number"
        :rules="[{ required: true, message: '开团商品数最少为2',validator:productNumber }]">
        <el-input type="number" v-model="form.product_number" class="max-w460"></el-input>
      </el-form-item>
    </div>

  </div>
</template>

<script>
  export default {
    inject: ['form'],
    data() {
      return {

      }
    },
    methods: {
      assembleLimitnum(rule, value, callback) {
        if (value === '') {
          callback(new Error('请输入开团人数'));
        } else if (value <= 1) {
          callback(new Error('开团人数最少为2'));
        } else {
          callback();
        }
      },

      orderNumber(rule, value, callback) {
        if (value === '') {
          callback(new Error('开团订单数'));
        } else if (value <= 1) {
          callback(new Error('开团订单数最少为2'));
        } else {
          callback();
        }
      },

      productNumber(rule, value, callback) {
        if (value === '') {
          callback(new Error('开团商品数'));
        } else if (value <= 1) {
          callback(new Error('开团商品数最少为2'));
        } else {
          callback();
        }
      }

    }
  };
</script>

<style></style>
